package com.didispace.config;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.didispace.aspect.AopAccess;
import com.didispace.aspect.MyException;

/**
 * 全局异常监控
 * @author wuyanzu
 * @version 1.0.0
 * @date 18/5/2 上午10:50.
 * @blog https://www.cnblogs.com/7motor28/
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    @AopAccess(desc="exception")
    public String defaultErrorHandler(HttpServletRequest req, Exception e){
    	return "Exception:"+e.getMessage();
    }
    
    @ExceptionHandler(value = MyException.class)
    @ResponseBody
    @AopAccess(desc="myexception")
    public String myErrorHandler(HttpServletRequest req, MyException e){
    	return "Exception:"+e.getMessage();
    }
    
}

